#include "GLObject.h"
#include "variables.h"

std::vector<GLObject*>* GLObject::objects = new std::vector<GLObject*>();

GLObject::GLObject()
{
}


GLObject::~GLObject(void)
{
}

glm::mat4 GLObject::transf(void){
	return this->transform;
}

void GLObject::draw( glm::mat4 global_transform){
          // YOUR CODE FOR HW 2 HERE. 
          // Set up the object transformations 
          // And pass in the appropriate material properties
		  glLoadIdentity();
		  glm::mat4 matx = glm::transpose((this->transform)*(global_transform));
		  glLoadMatrixf(&matx[0][0]);
			  //printf("obj->ambient: %.2f,%.2f,%.2f,%.2f\n", obj->ambient[0], 
			  //		obj->ambient[1], obj->ambient[2], obj->ambient[3]);   
			  //material properties
		  glUniform4fv(ambientcol ,1, this->ambient);
		  glUniform4fv(diffusecol ,1, this->diffuse );
		  glUniform4fv(specularcol ,1, this->specular );
		  glUniform4fv( emissioncol ,1, this->emission);
		  glUniform1f(shininesscol, this->shininess);

          // Actually draw the object
          // We provide the actual glut drawing functions for you.  
          if (this -> type == cube) {
            glutSolidCube(this->size) ; 
          }
          else if (this -> type == sphere) {
            const int tessel = 20 ; 
            glutSolidSphere(this->size, tessel, tessel) ; 
          }
          else if (this -> type == teapot) {
            glutSolidTeapot(this->size) ; 
          }else if (this->type == cone){
			const int tessel = 20;
			glutSolidCone(size,size, tessel , tessel);
		  }else if (this->type == cylinder){
			  GLUquadric *q = gluNewQuadric();
			const int tessel = 20;
			gluCylinder(q,this->size,this->size,this->size,tessel,tessel);
			
		  }
}